ccR.Racial = {
	-- DPS
	Blood_Fury =
	function()
		if ccR.Spell.Is.Ready(BLOOD_FURY) then
			if ccR.Player.Is.Melee() and (ccR.Player.Count(8) > 0 or (ccR.Target.Is.Attackable() and ccR.Target.Distance() <= 10)) then ccR.Cast.Spell(BLOOD_FURY) end
			if ccR.Player.Is.Ranged() and ccR.Player.Count(40) > 0 then ccR.Cast.Spell(BLOOD_FURY) end
		end
	end,
	Berserking =
	function()
		if ccR.Spell.Is.Ready(BERSERKING) then
			if ccR.Player.Is.Melee() and (ccR.Player.Count(8) > 0 or (ccR.Target.Is.Attackable() and ccR.Target.Distance() <= 10)) then ccR.Cast.Spell(BERSERKING) end
			if ccR.Player.Is.Ranged() and ccR.Player.Count(40) > 0 then ccR.Cast.Spell(BERSERKING) end
		end
	end,
	-- Spell Interuption Racial
	Arcane_Torrent =
	function()
		if ccR.Spell.Is.Ready(ARCANE_TORRENT) 
		and ccR.Player.Count(8) > 0
		and not IsStealthed()
		then
			for x = 1, # ccR_Enemies_Within_8 do
				local vUnit = ccR_Enemies_Within_8[x]
				if ccR.Unit.Exists(vUnit)
				and ccR.Unit.Is.CastingOrChanneling(vUnit)
				and not ccR.Unit.Is.Boss(vUnit)
				then
					ccR.Cast.Spell(ARCANE_TORRENT)
				end
			end
		end
	end,
	Warstomp =
	function(count)
		if count == nil then count = 3 end
		if ccR.Spell.Is.Ready(WARSTOMP)
		and ccR.Player.Count(8) >= count
		then
			ccR.Cast.Spell(WARSTOMP)
		end
	end,
	Will_of_the_Forsaken =
	function()
		if ccR.Spell.Is.Ready(WILL_OF_THE_FORSAKEN) then
			local eventIndex = C_LossOfControl.GetNumEvents()
			while (eventIndex > 0) do
				local _, _, text = C_LossOfControl.GetEventInfo(eventIndex)
				if text == LOSS_OF_CONTROL_DISPLAY_CHARM 
				or text == LOSS_OF_CONTROL_DISPLAY_FEAR
				or text == LOSS_OF_CONTROL_DISPLAY_SLEEP
				then
					ccR.Cast.Spell(WILL_OF_THE_FORSAKEN)
					return
				end
				eventIndex = eventIndex - 1
			end
		end
	end,
	Quaking_Palm =
	function()
		if ccR.Spell.Is.Ready(QUAKING_PALM) 
		and ccR.Player.Count(8) > 0
		and not IsStealthed()
		then
			for x = 1, # ccR_Enemies_Within_8 do
				local vUnit = ccR_Enemies_Within_8[x]
				if ccR.Unit.Exists(vUnit)
				and ccR.Unit.Is.CastingOrChanneling(vUnit)
				and ccR.Player.Is.Facing(vUnit)
				and not ccR.Unit.Is.Boss(vUnit)
				then
					ccR.Cast.Attack(QUAKING_PALM, vUnit)
				end
			end
		end
	end,
	-- Healing Racial
	Gift_of_the_Naaru =
	function(health)
		if health == nil then health = 80 end
		if ccR.Spell.Is.Ready(GIFT_OF_THE_NAARU) 
		and ccR.Player.Health() <= health
		then
			ccR.Cast.Spell(GIFT_OF_THE_NAARU, "player") 
		end
	end,
	-- Debuff Racials
	Stone_Form =
	function()
		if ccR.Spell.Is.Ready(STONEFORM) then
			for i = 0, 40 do
				local name, _, _, _, dispelType = UnitDebuff("player", i)
				if name ~= nil
				and dispelType ~= nil
				then
					if dispelType == "Poison"
					or dispelType == "Disease"
					or dispelType == "Curse"
					or dispelType == "Magic"
					or dispelType == "Bleed"
					then
						ccR.Cast.Spell(STONEFORM)
						return
					end
				end
			end
		end
	end,
	Escape_Artist =
	function()
		if ccR.Spell.Is.Ready(ESCAPE_ARTIST) then
			local eventIndex = C_LossOfControl.GetNumEvents()
			while (eventIndex > 0) do
				local _, _, text = C_LossOfControl.GetEventInfo(eventIndex)
				if text == LOSS_OF_CONTROL_DISPLAY_ROOT 
				or text == LOSS_OF_CONTROL_DISPLAY_SNARE
				then
					ccR.Cast.Spell(ESCAPE_ARTIST)
					return
				end
				eventIndex = eventIndex - 1
			end
		end
	end,
	Every_Man_For_Himself = 
	function()
		if ccR.Spell.Is.Ready(EVERY_MAN_FOR_HIMSELF) then
			local eventIndex = C_LossOfControl.GetNumEvents()
			while (eventIndex > 0) do
				local _, _, text = C_LossOfControl.GetEventInfo(eventIndex)
				if text == LOSS_OF_CONTROL_DISPLAY_ROOT 
				or text == LOSS_OF_CONTROL_DISPLAY_SNARE
				or text == LOSS_OF_CONTROL_DISPLAY_STUN_MECHANIC
				or text == LOSS_OF_CONTROL_DISPLAY_STUN
				or text == LOSS_OF_CONTROL_DISPLAY_FEAR
				or text == LOSS_OF_CONTROL_DISPLAY_HORROR
				then
					ccR.Cast.Spell(EVERY_MAN_FOR_HIMSELF)
				end
				eventIndex = eventIndex - 1
			end
		end
	end,
}
setmetatable(ccR.Racial, ccR)